Skip to content

Glasgow | 25 SDC NOV | Katarzyna Kazimierczuk | Sprint 2 | Lru cache#118

Open
katarzynakaz wants to merge 2 commits intoCodeYourFuture:mainfrom
katarzynakaz:lru-cache
Open

Glasgow | 25 SDC NOV | Katarzyna Kazimierczuk | Sprint 2 | Lru cache#118
katarzynakaz wants to merge 2 commits intoCodeYourFuture:mainfrom
katarzynakaz:lru-cache

Conversation

@katarzynakaz
Copy link

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

Sprint 2 lru cache task is implemented.

@katarzynakaz katarzynakaz added 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Feb 20, 2026
Copy link

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you implement the LruCache as a class?

Comment on lines +59 to +101
#before i did it this was but was looping over each item and did not
#fit the required complexity
# def get_old(key):
# for item in our_list:
# if item["key"] == key:
# item["tracker"] = time.time()
# our_list.remove(item)
# our_list.insert(0, item)
# return item["value"]
# return None

#and before tried with an id not timestamp
# tracker_number = 0

# def set(key, value):
# global tracker_number, our_list, lookup_map


# wrapped_item = {
# "key": key,
# "value": value,
# "tracker": tracker_number
# }


# tracker_number += 1

# our_list.insert(0, wrapped_item)
# lookup_map[key] = wrapped_item

# and the loop
# def get_old(key):
# global tracker_number, our_list
# for item in our_list:
# if item["key"] == key:
# item["tracker"] = tracker_number
# tracker_number += 1

# our_list.remove(item)
# our_list.insert(0, item)

# return item["value"]
# return None No newline at end of file
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this code are not used, can you remove them to keep the code clean?

Comment on lines +3 to +4
our_list = []
lookup_map = {}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OrderedDict is probably more efficient.

wrapped_item = {
"key": key,
"value": value,
"tracker": time.time()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the value of property tracker used anywhere in your implementation to determine the order of the item? Do you need this property?

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants